<?php
require_once ROOT_PATH.'/include/memcache/nocacheDB.php';

class memcacheDB extends nocacheDB{
	var $memcached ;
	var $memche_sql;
	var $time_live=1;
	var $result;
	function memcacheDB($sql){
		include ROOT_PATH . 'setting/memcached.php';
		$this->memcached = new memcached($config['memcached']);
		$this->memche_sql=$this->createMemcacheKey($sql);

		$this->time_live=rand($config['memcached_propety']['min_live'],$config['memcached_propety']['max_live']);
	}

	function getvalue(){
		$this->result=$this->memcached->get($this->memche_sql);
		return $this->result;
	}

	function getresult(){
		return $this->result;
	}

	function setvalue($value){
		$this->result=$value;
		$this->memcached->set($this->memche_sql,$value,$this->time_live);
	}

    function deletememcache(){
    	$this->result=null;
        $this->memcached->delete($this->memche_sql);
    }

	function createMemcacheKey($filekey){
		return md5($filekey);
	}
}
?>